<script type="text/javascript"><!--//--><![CDATA[//><!--
	  var emails = <?php echo $alluser;?>;
	
	$(document).ready(function() {
		
		// Setup Form
		$('#form_master').setupForm([
			{ name: 'from', type: 'text', size: 'medium', maxlength: 40, readonly:true},
			{ name: 'to', type: 'text', size: 'long', maxlength: 300},
			{ name: 'subject', type: 'text', size: 'long', maxlength: 200},
			{ name: 'message', type: 'textarea', size: 'long', maxlength: 8000}
		], <?php echo json_encode($data); ?>);
		
		
		// Set Action Button
		
		<?php 
		if ($mode=='create'){
		?>
			var buttons = [{ label: 'Send', icon: 'save', onclick: function(){ $('#form_master').submitForm('/'+controller+'/ajax_post', {  onComplete : function(){ loadPage('/'+controller+'/index'); }});}},
					   { label: 'Close', icon: 'cancel', onclick: function() { loadPage('/'+controller+'/Index'); } }];
		
		<?php
		}else{
		?>
			var buttons = [{ label: 'Close', icon: 'cancel', onclick: function() { loadPage('/'+controller+'/Index'); } }];
		
		<?php
		}
		?>
		setAction(buttons);

		$('#tt').tabs({  
			border:false
		});  

		$("#to").autocomplete(emails, {
            multiple: true,
            minChars: 1,
            matchContains: "word",
            autoFill: false,
            formatItem: function(row, i, max) {
                //return "\"" + row.name + "\" &lt;" + row.to + "&gt;";
                return row.name + "&lt;" + row.to + "&gt;";
            },
            formatMatch: function(row) {
                return row.name + " " + row.to;
            },
            formatResult: function(row, i, max) {
                //return "\"" + row.name + "\" <" + row.to + ">";
               return row.to;
            }
        });
		
		// Focus at First Object
		$('#form_popup').focusFirst();
	});
//--><!]]></script>
				
<div id="form_master_message" style="display:none;"></div>

<div id="form_master">
	<table class="tb_form" style="display:none; margin:10px;" cellpadding="0" cellspacing="0">
		<tr>
			<td class="label">From</td>
			<td><input id="from" /></td>
		</tr>
		<tr>
			<td class="label">To</td>
			<td><input id='to' /></td>
		</tr>
		<tr>
			<td class="label">Subject</td>
			<td><input id='subject' /></td>
		</tr>
		<tr>
			<td class="label">Message</td>
			<td><input id='message' /></td>
		</tr>
	</table>
</div>

